<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>radial gradient</title>
	</head>
	<body>
		<canvas width="600" height="600"></canvas>
		<script src="/js/mesh.js"></script>
		<script>
			const {Renderer, Figure2D, Mesh2D} = meshjs;

			const canvas = document.querySelector('canvas');
			const renderer = new Renderer(canvas, {
			  contextType: 'webgl',
			});

			const figure = new Figure2D();
			figure.rect(0, 0, 600, 600);

			const mesh = new Mesh2D(figure);
			// mesh.setStroke({
			//   thickness: 100,
			//   color: [1, 0, 1, 1],
			// });

			mesh.setFill({
			  color: [1, 0, 0, 1],
			});

			// 1. 坐标变换
			mesh.setRadialGradient({
			  vector: [250, 200, 70, 300, 225, 240],
			  colors: [
			    {offset: 0, color: [1, 0, 0, 1]},
			    {offset: 0.33, color: [1, 1, 0, 1]},
			    {offset: 0.66, color: [0, 1, 0, 1]},
			    {offset: 1.0, color: [0, 0, 1, 1]},
			  ],
			  type: 'fill',
			});

			// mesh.translate(100, 100);
			// mesh.rotate(Math.PI / 4, [300, 300]);

			renderer.drawMeshes([mesh]);
		</script>
	</body>
</html>
